package com.osdp.auth.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
@ApiModel(value="登录对象", description="登录对象")
public class LoginModel {
    private final static String MANAGE_PLATFORM_STATUS = "1";

    private final static String GATEWAY_SERVICE_STATUS = "2";

    /**
     * 默认为1，就是要判断租户的。 如果是网关管理，配置中心等，可以传输0。代表不需要租户。
     */
    @ApiModelProperty(value = "管理平台")
    private String manage = "1";

    private String ignoreCaptcha = "0";

    @ApiModelProperty(value = "账号")
    private String username;

    @ApiModelProperty(value = "密码")
    private String password;

    @ApiModelProperty(value = "验证码")
    private String captcha;

//    @ApiModelProperty(value = "Token")
//    private String token;

//    @ApiModelProperty(value = "验证码")
//    private String refreshToken;



    public boolean isManagePlatform(){
        return StringUtils.equalsIgnoreCase(MANAGE_PLATFORM_STATUS,this.manage);
    }

    public boolean isGatewayService(){
        return StringUtils.equalsIgnoreCase(GATEWAY_SERVICE_STATUS,this.manage);
    }

    public boolean isOtherPlatform(){
        return !isManagePlatform()&&!isGatewayService();
    }

    /**
     * 是否需要验证码 ，1：不需要，0：需要
     * @return
     */
    public boolean isIgnoreCaptcha(){
        return StringUtils.equals("1",ignoreCaptcha);
    }

    public boolean hasTenant(){
        return !(username.indexOf("#") == -1);
    }
}
